<?php
/**
 * @package Autogenerator for Joomla!
 * @version 3.0.0
 * @author Truong Cong Duc <truongcongduc4@gmail.com>
 * @link autogenerator.blogspot.com
 * @copyright (c) 2013, Truong Cong Duc
 * @license GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

JLoader::register('AutogeneratorHtmlXmlType', AUTOGENERATOR_DIR_ROOT . '/lib/xmltype.php');

class AutogeneratorViewXml_types extends JViewLegacy
{
	protected $items;

	protected $pagination;

	protected $state;

	public function display($tpl = null)
	{
		AutogeneratorHelper::addSubmenu('xml_types');
	
		$this->items		= $this->get('Items');
		$this->pagination	= $this->get('Pagination');
		$this->state		= $this->get('State');
		
		$this->addToolbar();
		
		$this->addFilter();
		
		parent::display($tpl);
	}
	
	protected function addToolbar()
	{
		JToolbarHelper::title(JText::_('COM_AUTOGENERATOR_XML_TYPES_TITLE'));
		
		JToolbarHelper::addNew('xml_type.add');
        JToolbarHelper::editList('xml_type.edit');
        JToolbarHelper::deleteList(JText::_('COM_AUTOGENERATOR_MESSAGE_CONFIRM_DELETE'), 'xml_types.delete', 'JTOOLBAR_DELETE');
	}
	
	protected function addFilter()
	{
		JHtmlSidebar::setAction('index.php?option=com_autogenerator&view=xml_types');
		
        // Add filter.
		JHtmlSidebar::addFilter(
			JText::_('COM_AUTOGENERATOR_XML_TYPE_SELECT_IN_LIBRARY'),
			'filter_lib_id',
			JHtml::_('select.options', AutogeneratorHtmlXmlType::options(), 'value', 'text', $this->state->get('filter.lib_id'))
		);
        
		$this->sidebar = JHtmlSidebar::render();
	}
	
	protected function getSortFields()
	{
		return array(
			'axt.id' => JText::_('JGRID_HEADING_ID')
		);
	}
}
